angular.module('pmsService', ['ngResource'])
  /* 证书*/
  .factory('Certificate', function($resource) {
    return $resource('/certificates/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'},
        require_certificate_organs: {method: 'GET', isArray: true, url: '/certificates/:id/require_organs.json'},
        analysis: {method: 'GET', isArray: true, url: '/certificates/analysis.json'}}
      );
    })
  /* 岗位 */
  .factory('Position', function($resource) {
    return $resource('/positions/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'},
        query_position_standard: {method: 'GET', isArray:true, url: '/organizations/:organization_id/position_standard.json'}}
      );
    })
 /* 岗位类型 */
  .factory('Nature', function($resource) {
    return $resource('/position/natures/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'}}
      );
    })
 /* 人员管理 */
  .factory('Employee', function($resource) {
    return $resource('/employees/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'},
        add_certificate: {method: 'POST', url: '/employee/certificates'}}
      );
    })
  /* 人员证书 */
  .factory('EmployeeCertificate', function($resource) {
    return $resource('/employee/certificates/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'},
        list_will_valid_certificates: {method: 'GET', isArray: true, url: '/employee/certificates/list_will_valid_certificates.json'},
        list_valid_certificates: {method: 'GET', isArray: true, url: '/employee/certificates/list_valid_certificates.json'},
        query_will_certificates: {method: 'GET', isArray: true, url: '/employee/certificates/query_will_certificates.json'}}
      );
    })
  /* 人员岗位 */
  .factory('EmployeePosition', function($resource) {
    return $resource('/employee/positions/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'}}
      );
    })
 /* 管理单位管理 */
  .factory('RequireCertificateOrgan', function($resource) {
    return $resource('/require_certificate_organs/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'}}
      );
    })
 /* 持证标准管理 */
  .factory('PositionCertificateStandard', function($resource) {
    return $resource('/position_certificate_standards/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'},
        list_lost_certificate: {method: 'GET', isArray: true, url: '/position_certificate_standards/list_lost_certificate.json'},
        get_position_standards: {method: 'GET', isArray: true, url: '/position_certificate_standards/get_position_standards/:position_id.json'}}
      );
    })
 /* 组织类型 */
  .factory('OrganizationCategory', function($resource) {
    return $resource('/organization/categories/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'},
        position_standard: {method: 'GET', isArray: true, url: '/organization/categories/:id/position_standard.json'}}
      );
    })
  /* 组织等级 */
  .factory('OrganizationRank', function($resource) {
    return $resource('/organization/ranks/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'}}
      );
    })

  /* 组织 */
  .factory('Organization', function($resource) {
    return $resource('/organizations/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'},
        query_position_standard: {method: 'GET', isArray:true, url: '/organizations/:id/position_standard.json'},
        get_tree: {method: 'GET', isArray: true, url: '/organizations/tree.json'},
        assignment_position_standard: {method: 'POST', url: '/organizations/:id/assignment_position_standard.json'},
        get_employee_and_positions: {method: 'GET', isArray: true, url: '/organizations/:id/get_employee_and_positions.json'},
        require_certificate_organs: {method: 'GET', isArray:true, url: 'organizations/:id/require_certificate_organs.json'}}
      );
    })
  /* 组织类型岗位配置*/
  .factory('OrganizationCategoryPositionStandard', function($resource){
    return $resource('/organ_category_position_standards/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'},
        query_position_standard: {method: 'GET', isArray:true, url: '/organ_category_position_standards/query_position_standard/:category.json'}}
      );
    })

  /* 岗位标准分配*/
  .factory('PositionStandardAssignment', function($resource){
    return $resource('/position_standard_assignments/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'}}
      );
    })

  /* 职员合同*/
  .factory('EmployeeContract', function($resource){
    return $resource('/employee/contracts/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'},
        list_will_valid_contracts: {method: 'GET', isArray: true, url: '/employee/contracts/list_will_valid_contracts.json'},
        list_valid_contracts: {method: 'GET', isArray: true, url: '/employee/contracts/list_valid_contracts.json'}}
      );
    })

  /* 合同类型*/
  .factory('ContractType', function($resource){
    return $resource('/contract_types/:id.json',
      {id: '@id'},
      { update: {method: 'PUT'}}
      );
    })
  ;
